<?php
$username=$_POST['username'];
$password=$_POST['password'];

$con = mysqli_connect('localhost','root','root'); 

if(!$con){ //如果失败
    die('连接数据库失败'.mysqli_error()); //显示出错误信息
}
mysqli_select_db($con,"login"); //选择需要使用的数据库

$sql = "insert into login 
        values ('$username','$password')";

$result = mysqli_query($con, $sql );

if(!$result)
{
    //die('注册失败 ' . mysqli_error($con));//页面显示
    echo("<script> alert('注册失败');parent.location.href='/blogger/register.html'; </script> " . mysqli_error($con));//弹窗返回注册页面
}
else{

echo "<script> alert('注册成功');parent.location.href='/blogger/login.html'; </script>";//弹窗并跳转

mysqli_close($con);}

?>
